#搜索结果页面 页面类

from selenium.webdriver.common.by import By

from utils.page_base import PageBase

class PageSerarchResult(PageBase):
    #/index.php?controller=site&action=search_list&word=%E4%B8%B9%E6%9D%B0
    loc_errorTip=By.CSS_SELECTOR,"p.no_tip"

    def __init__(self,driver,base_url):
        PageBase.__init__(self,driver,base_url)

    #判断搜索结果中是否有该商品
    def isExists(self,sp_title):
        eles=self.driver.find_elements(By.CSS_SELECTOR,"section.goods_list > ul >li")
        for x in eles:
            ele_span=x.find_element(By.CSS_SELECTOR,"p.goods_title > span")
            title=ele_span.text.strip()
            if title==sp_title:
                return True
        else:
            return False

    #获取“对不起，没有找到相关商品”
    def getErrorTip(self):
        return self.getEleText(PageSerarchResult.loc_errorTip)